<section id="sectionWelcome">
    <?php include_component('componente','welcome') ?>
</section>


<section id="bloqueHeader">  <?php include_component('componente','header') ?>    </section>
<section id="bloqueBaner">      </section>
<section id="sectionNav"><?php include_component('componente','nav') ?> </section>


<section id="bloqueBuscador"> <?php include_component('componente','search') ?>    </section>
<?php include_component('componente','documento_subir2') ?>

<div class="contenedor_documento">
    <div class="contenedor_datos2">
       
        <div class="contenedor_descarga" >
          <?php if($documento->getTipoDocumento()->getDescripcion()=="tesis"){ ?>
                <?php $tipo_principal="tesis.jpg" ?>
          <?php }else{ if($documento->getTipoDocumento()->getDescripcion()=="investigacion"){ ?>
                <?php $tipo_principal="investigacion.jpg" ?>
         <?php }else{ ?>
                <?php $tipo_principal="presentacion.jpg" ?>
         <?php }}?>
        
		     <?php echo image_tag("componente/flecha_subir1.png",'class="check" id="check_rojo" '); ?>
           <?php echo image_tag("componente/check.png",'class="check" id="check_verde" style="visibility: hidden;" '); ?>

		   
           <?php if($documento->getImagenPortada()!=''){ ?>
            <?php $DS = DIRECTORY_SEPARATOR; ?>
           <?php if(file_exists(sfConfig::get('sf_upload_dir').$DS."documento".$DS.$documento->getImagenPortada())){ ?>
           <?php echo image_tag('/uploads/documento/'.$documento->getImagenPortada(),'class="imag_portada" size=152x114'); ?>
           <?php } ?>
            <?php }else { ?>
                  <?php echo image_tag('/uploads/documento/'.$tipo_principal,'class="imag_portada" size=152x114'); ?>
            <?php }?>
            <div class="detalle_imagen" >
            <span style="text-align: left;"><?php echo $documento->getImagenPortada(); ?></span><br>
            <span style="text-align: left;"><?php echo image_tag("botonera/eliminar.png") ?><a class="href" href="<?php echo url_for('@delete_documento_actual?id_doc='.$documento->getId()) ?>">Eliminar</a></span><br>
         </div>
        </div>



              <?php for ($i=1;$i<2;$i++){ ?>

         <form style="display: inline-block; display: inline-block;" id="frm_<?php echo $i ?>" name="frm_<?php echo $i ?>" action="<?php echo url_for('documentos/uploadFile') ?>" method="post" enctype="multipart/form-data" target="upload_target_<?php echo $i ?>" onsubmit="startUpload('<?php echo $i ?>');" >

                      <div style="display: inline-block;width: 158px;height: 79px;vertical-align: text-bottom;">
                                       <div style="display: inline-block;">                                         
                                          <div class="qq-upload-button" style="position: relative; overflow: hidden; direction: ltr;"  id="subir_doc">
                                                <div>Subir</div>
                                                    <input  type="file"   class="upload_archivo_documento" onchange="uploadFileScript('<?php echo $i ?>')" name="fileIng" id="fileIng" style="position: absolute; right: 0px; top: 0px; font-family: Arial; font-size: 118px; margin: 0px; padding: 0px; cursor: pointer; opacity: 0;">
                                          </div>
													<div class="listo_upload" style="position: relative; overflow: hidden; direction: ltr;visibility: hidden;" id="listo_subida">
                                          </div>
                                           <input type="hidden" value="<?php echo $i ?>" id="id-file" name="id-file" />
                                           <input type="hidden" value="<?php echo $idDocumento; ?>" id="id-ficha" name="id-ficha" />

                                       </div>
                                       <div style="display: inline-block;visibility: hidden;float: left;" id="image_load">
                                          <?php echo image_tag('loadCometa.gif') ?>
                                       </div>
                                       <div style="display: inline-block;margin-top: 5px;" id="image_pro"></div>
                                       <div style="display: inline-block;visibility: hidden;" id="delete_image_<?php echo $i ?>"></div>

                       </div>

                                   <iframe id="upload_target_<?php echo $i ?>" name="upload_target_<?php echo $i ?>" src="#" style="width:0;height:0;margin: 0px; visibility: hidden;"></iframe>
          </form>

      <?php } ?>
    <div class="titulo_lista_documento">Lista de Documentos<?php echo image_tag("componente/flecha_subir1.png") ?></div>
  <div style="text-align: left;">
       <?php foreach ($listarDocumento_usuario as $row) {?>
      <?php if($row->getTipoDocumento()->getDescripcion()=="tesis"){ ?>
                <?php $tipo="tesis.jpg" ?>
      <?php }else{ if($row->getTipoDocumento()->getDescripcion()=="investigacion"){ ?>
                <?php $tipo="investigacion.jpg" ?>
      <?php }else{ ?>
                <?php $tipo="presentacion.jpg" ?>
      <?php }}?>

       <div class="contenedor_descarga" >
            <?php echo image_tag("componente/check.png",'class="check"'); ?>
          
           <?php $DS = DIRECTORY_SEPARATOR; ?>
          <?php if($row->getImagenPortada()!=''){ ?>
           <?php if(file_exists(sfConfig::get('sf_upload_dir').$DS."documento".$DS.$row->getImagenPortada())){ ?>
           <?php echo image_tag('/uploads/documento/'.$row->getImagenPortada(),'size=152x114') ?>
            <?php } ?>

           <?php }else{ ?>
                <?php echo image_tag('/uploads/documento/'.$tipo,'size=152x114'); ?>
               
           <?php } ?>
            <div class="detalle_imagen" >
            <span style="text-align: center;"><?php echo $row->getImagenPortada(); ?></span><br>
            <span style="text-align: center;"><?php echo image_tag("botonera/eliminar.png") ?><a class="href" href="<?php echo url_for('@delete_documento?id_documento='.$row->getId().'&id_actual='.$documento->getId()); ?>">Eliminar</a></span><br>
            </div>
        </div>
      <?php } ?>

   </div>
    <br>





    

    </div>
</div>



<script type="text/javascript">

 function sucessUpLoad(data)
    {

        $("#image_load").css("visibility","hidden");
        $("#subir_doc").css("visibility","hidden");
        $("#check_rojo").css("visibility","hidden");
        $("#check_verde").css("visibility","visible");
        $("#listo_subida").css("visibility","visible");
        $("#image_pro").html("<a class='mensaje_documento' href='<?php echo url_for('documentos/fichaDocumento')?>'>Registra otro documento</a>");


    }

    function startUpload(id)
    {
        $("#image_load").css("visibility", "visible");
        return true;
    }

    function stopUpload(data)
    {


          var myObject = eval('(' + data + ')');
             
          if (myObject.success)
          {
              
                sucessUpLoad(myObject.id);
          }
          else
          {
                errorUpLoad(myObject.id);
          }
    }

    function uploadFileScript(id)
    {
        $("#frm_"+id).submit();
    }
</script>